package head.first.model.state.demo2;

/**
 * Created by yiyongyao on 2018/2/27.
 * 糖果机状态--已投币
 */
public class hasQuarterState implements State
{

    GumballMachine gumballMachine;

    public hasQuarterState(GumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    @Override
    public void insertQuarter(GumballMachine gumballMachine) {

        System.out.println("已经投币,不需要再投币!");

    }

    @Override
    public void ejectQuarter(GumballMachine gumballMachine) {
        System.out.println("退还已投的钱币!");
        gumballMachine.setState(gumballMachine.getNoQuarterState());
    }

    @Override
    public void turnCrank(GumballMachine gumballMachine) {

        System.out.println("转动曲柄,等待出糖!");
        gumballMachine.setState(gumballMachine.getSoldState());

    }

    @Override
    public void dispence(GumballMachine gumballMachine) {
        System.out.println("无法出糖,请转动曲柄!");

    }
}
